package com.zdemo.leak;

import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicInteger;

public class HelotFactory implements ThreadFactory {
	
	private static final AtomicInteger created = new AtomicInteger();

	@Override
	public Thread newThread(Runnable r) {
		Thread helotThread = new Thread(r);
		helotThread.setName("helot-" + created.incrementAndGet());// 设置奴隶姓名
		helotThread.setUncaughtExceptionHandler(new EscapeHandler());// UEHLogger就是报警器
		return helotThread;
	}

}
